package ch02_data.generics.problem;

import java.lang.reflect.Array;

/**
 * @author guodd
 * @version 1.0 use jdk 1.8
 */
public class Erased<T> {
    Class<T> c;

    public Erased(Class<T> c) {
        this.c = c;
    }

    public Erased() {

    }

    public void f(String a) throws Exception {
        T t = c.getConstructor().newInstance(); // 这个类需要有默认构造器，反射知识
        T[] o = (T[]) Array.newInstance(c, 10);
        boolean instance = c.isInstance(a);
        System.out.println(instance);
    }

    public static void main(String[] args) throws Exception {
        Erased<String> objectErased = new Erased<>();
        objectErased.f("a");
    }
}
